/**
 * 
 */
package com.edu.lawdoc.pvg;


/**
 * @author Administrator
 *
 */
public class Pvg {

	/**
	 * 用来保存操作者的信息的线程变量
	 * 
	 * ThreadLocal 找到变量必须具备两个键值
	 * 1.是thread本身的id
	 * 2.是ThreadLocal实例
	 *
	 * id很容易一样，ThreadLocal如果new一个新的，则是找不到变量的
	 */
	private final static ThreadLocal<PvgUser> pvg = new ThreadLocal<PvgUser>();

	/**
	 * 保存openid
	 */
	private final static ThreadLocal<String> openIdHolder = new ThreadLocal<String>();

	public static void setPvg(PvgUser oPvgUser) {
		pvg.set(oPvgUser);
	}

	public static void removePvg() {
		pvg.remove();
	}

	public static PvgUser getPvg() {
		return pvg.get();
	}

	public static String getPvgName() {
		PvgUser user = pvg.get();
		if (user == null)
			return null;
		return user.getName();
	}

	public static String getPvgRole() {
		PvgUser user = pvg.get();
		if (user == null)
			return null;
		return user.getRole();
	}

	public static String getSn() {
		PvgUser user = pvg.get();
		if (user == null)
			return null;
		return user.getSn();
	}

	public static void setOpenId(String openId) {
		openIdHolder.set(openId);
	}

	public static void removeOpenId() {
		openIdHolder.remove();
	}

	public static String getOpenId() {
		return openIdHolder.get();
	}
}
